package com.rongshu.widget;


import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

import com.rongshu.R;

/**
 * created by zhengeweis on 2018/1/7.
 * description：
 */

public class PraiseNumDialog extends Dialog {
    public PraiseNumDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    public static class Builder {

        private Context context; // 上下文对象
        private int mMainLayout = R.layout.fragment_praise_dialog_view;
        private int praiseNum;
        private int type = 0;

        public Builder(Context context) {
            this.context = context;
        }

        public Builder setType(int type) {
            this.type = type;
            return this;
        }

        public Builder setPrarseNum(int prarseNum) {
            this.praiseNum = prarseNum;
            return this;
        }

        public PraiseNumDialog create() {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final PraiseNumDialog dialog = new PraiseNumDialog(context, R.style.CustomDialog);
            View layout = inflater.inflate(mMainLayout, null);
            dialog.addContentView(layout, new ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
            TextView praise = layout.findViewById(R.id.praise_num);
            TextView know = layout.findViewById(R.id.know);
            praise.setText(type == 0 ? "你已获得" + praiseNum + "个赞，加油哦！" : "Ta已获得" + praiseNum + "个赞！");
            know.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    dialog.dismiss();
                }
            });
            return dialog;
        }

    }

    @Override
    public void show() {
        super.show();
    }
}
